package com.mightybird.designpattern.structural.flyweight.concrete;

import com.mightybird.designpattern.structural.flyweight.Flyweight;

import java.util.ArrayList;
import java.util.List;

public class Couple extends Flyweight {
    private List<Flyweight> flyweights = new ArrayList<>();

    public void add(Flyweight flyweight) {
        flyweights.add(flyweight);
    }

    public void remove(Flyweight flyweight) {
        flyweights.remove(flyweight);
    }

    @Override
    public void operation(int age) {
        flyweights.forEach(flyweight -> flyweight.operation(age));
    }
}
